import { segment } from "oicq";
import fetch from "node-fetch";


const _path = process.cwd();


export class wallpaper extends plugin {
    constructor () {
        super({
            name: 'wallpaper',
            dsc: 'loli',
            event: 'message',
            priority: 500,
            rule: [

                {
                    reg: "^#?(随机二次元|来点二次元|来点萝莉|来点loli)$",
                    fnc: 'loli'
                },

            ]
        })

    }

    async loli(e) {
        //e.msg 用户的命令消息
        console.log("用户命令：", e.msg);
        //执行的逻辑功能
        let url = `http://api.weboss.hk/random/api.php`;
        let res = await fetch(url).catch((err) => logger.error(err));

        let msg = [segment.at(e.user_id), segment.image(res.url)];

        //发送消息
        e.reply(msg);

        return true; //返回true 阻挡消息不再往下

    }
}
